importScripts('./ManKey.js')

function postEvent(keyId,keyEvent){
   self.postMessage({
        keyId,keyEvent
    })
}


let mankeyList=[new ManKey(0,postEvent),new ManKey(1,postEvent)];


onmessage = e => {
   //console.time("A");
    switch (e.data.m){
        case "up":{
            mankeyList[e.data.p].Button_Up();
            break;
        }
        case "down":{
            mankeyList[e.data.p].Button_Down();
            break;
        }
    }
    //console.timeEnd("A");
}

setInterval(() => {
   // console.time("B");
    let t= new Date().getTime()
    for (let i=0;i<mankeyList.length;i++){
        mankeyList[i].OnUiTick(t)
    }
    //console.timeEnd("B");
}, 20);

